package model_layer;



/**
 * The Class ProductPart.
 */
public class ProductPart
{
	
	private float retail_price;
	private float total_price;
	private int amount;
	private Product product;
	
	/**
	 * Instantiates a new product part.
	 */
	public ProductPart()
	{
		
	}
	
	/**
	 * Gets the amount.
	 *
	 * @return the amount
	 */
	public int getAmount()
	{
		return amount;
	}

	/**
	 * Gets the product.
	 *
	 * @return the product
	 */
	public Product getProduct()
	{
		return product;
	}

	/**
	 * Sets the amount.
	 *
	 * @param amount the new amount
	 */
	public void setAmount(int amount)
	{
		this.amount = amount;
	}

	/**
	 * Sets the product.
	 *
	 * @param product the new product
	 */
	public void setProduct(Product product)
	{
		this.product = product;
		if(retail_price == 0)
		{
			retail_price = product.getLast_retail_price();
		}
		product.setLast_retail_price(retail_price);
	}
	
	/**
	 * Gets the retail_price.
	 *
	 * @return the retail_price
	 */
	public float getRetail_price()
	{
		return retail_price;
	}

	/**
	 * Sets the retail_price.
	 *
	 * @param retail_price the new retail_price
	 */
	public void setRetail_price(float retail_price)
	{
		this.retail_price = retail_price;
		if(product != null)
		{
			product.setLast_retail_price(retail_price);
		}
	}

	/**
	 * Gets the total_price.
	 *
	 * @return the total_price
	 */
	public float getTotal_price()
	{
		return total_price;
	}

	/**
	 * Sets the total_price.
	 *
	 * @param total_price the new total_price
	 */
	public void setTotal_price(float total_price)
	{
		this.total_price = total_price;
	}

	/**
	 * Calculate_price.
	 */
	public void calculate_price()
	{
		total_price = retail_price * amount;
	}
	
	
}
